package com.tianruan.psychological;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

@SpringBootApplication
// 开启权限注解
// @PreAuthorize() 在进入方法前检验权限
// @PostAuthorize() 在方法返回值后检验权限
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)

public class PsychologicalApplication {

    @Autowired
    private RedisConnectionFactory redisConnectionFactory;
    /**
     * redis token 配置
     */
    @Bean(value = "redisTokenStore")
    public TokenStore redisTokenStore() {
        return new RedisTokenStore(redisConnectionFactory);
    }

    public static void main(String[] args) {
        SpringApplication.run(PsychologicalApplication.class, args);
    }

}
